package patterns.factory;

/**
 * Created by lenovo on 2016/11/22 0022.
 */
public class ShapeFactory {
    /**
     * 获取Shape的方法，返回的是IShape接口类型
     * @param type 接收Shapes枚举中的类型
     * @return 返回IShape的接口对象
     */
    public IShape getShape(Shapes type) {
        if (type == null) {
            return null;
        }
        if (type.equals(Shapes.RECT)) {
            return new Rectangle();
        } else if (type.equals(Shapes.CIRCLE)) {
            return new Circle();
        } else if (type.equals(Shapes.SQUARE)) {
            return new Square();
        }
        return null;
    }
}
